package com.bawei.week.visit

import androidx.lifecycle.MutableLiveData
import com.bawei.lib_base.entity.VisitBean
import com.bawei.lib_base.entity.VisitBeanItem
import com.bawei.lib_base.mvvm.BaseViewModel
import com.bawei.lib_base.utils.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class VisitViewModel @Inject constructor(val apiService: ApiService) : BaseViewModel(){
    val visitSuc = MutableLiveData<VisitBean>()

    val visitAddSuc = MutableLiveData<VisitBeanItem>()

    var visitDetailSuc = MutableLiveData<VisitBeanItem>()

    fun getVisit(){
        httpRetrofit({apiService.getVisit()},visitSuc :: postValue)
    }

    fun getVisitStatus(status : String){
        httpRetrofit({apiService.getVisitStatus(status)},visitSuc :: postValue)
    }

    fun getVisitName(name : String){
        httpRetrofit({apiService.getVisitName(name)},visitSuc :: postValue)
    }

    fun getVisitAdd(visitBeanItem: VisitBeanItem){
        httpRetrofit({apiService.getVisitAdd(mapToBody(visitBeanItem))},visitAddSuc :: postValue)
    }

    fun getVisitDetail(id : Int){
        httpRetrofit({apiService.getVisitDetail(id)},visitDetailSuc :: postValue)
    }

    fun getVisitApprove(id : Int){
        httpRetrofit({apiService.getVisitApprove(id)},visitDetailSuc :: postValue)
    }

    fun getVisitReject(id : Int){
        httpRetrofit({apiService.getVisitReject(id)},visitDetailSuc :: postValue)
    }

}